package com.jcfk.eam.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 资产大类
 */
public enum AssetStatus {
    /**
     * 在用
     */
    EXERCISE(1,"在用"),

    /**
     * 停用
     */
    STOP_USING(2,"停用"),

    /**
     * 在库
     */
    STOCK(3,"在库"),

    /**
     * 封装
     */
    PACKAGE(4,"封装"),

    /**
     * 报废
     */
    SCRAP(5,"报废"),

    /**
     * 量检具
     */
    LOSE(6,"丢失");

    /**
     * 编码
     */
    private Integer value;

    /**
     * 名称
     */
    private String desc;

    AssetStatus(Integer value, String desc){
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue(){
        return value;
    }

    public String getCode(){
        return value.toString();
    }

    public String getDesc(){
        return desc;
    }

    private static final Map<Integer, AssetStatus> stringToEnum = new HashMap<>();

    static {
        for (AssetStatus state : AssetStatus.values()) {
            stringToEnum.put(state.getValue(), state);
        }
    }

    public static AssetStatus fromString(Integer code) {
        return stringToEnum.get(code);
    }

    public Map<String,String> getMap(){
        Map<String,String> map=new HashMap<>();
        map.put(EXERCISE.getCode(), EXERCISE.getDesc());
        map.put(STOP_USING.getCode(), STOP_USING.getDesc());
        map.put(STOCK.getCode(), STOCK.getDesc());
        map.put(PACKAGE.getCode(), PACKAGE.getDesc());
        map.put(SCRAP.getCode(), SCRAP.getDesc());
        map.put(LOSE.getCode(), LOSE.getDesc());
        return map;
    }
}
